home *** CD-ROM | disk | FTP | other *** search
- package horst;
-
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Rectangle;
- import java.awt.Shape;
-
- public class HRView extends BlockView {
- int m_size;
- int m_borderSize;
- int m_width;
- boolean m_bNoShade;
- float m_pctWidth;
-
- public HRView(View parent, Element e, HTMLPane container) {
- super(parent, e, container);
- }
-
- protected int getPreferredSpan(int axis) {
- if (axis == 0) {
- return this.m_size + 2 * this.m_borderSize + super.m_insets.top + super.m_insets.bottom;
- } else {
- return this.m_width > 0 ? this.m_width : this.m_size + 2 * this.m_borderSize;
- }
- }
-
- protected void init() {
- this.m_borderSize = 1;
- ((View)this).setInsets(2, 0, 2, 0);
- this.m_bNoShade = super.m_elem.isAttributeDefined("noshade");
- this.m_size = Utilities.setIntegerProperty(1, "size", super.m_elem.getAttributes());
- this.m_pctWidth = Utilities.setPercentageProperty(-1.0F, "width", super.m_elem.getAttributes());
- super.m_alignment = Utilities.setAlignmentProperty(false, 1, "align", super.m_elem.getAttributes());
- this.m_width = Utilities.setIntegerProperty(-1, "width", super.m_elem.getAttributes());
- }
-
- protected boolean isContainerView() {
- return false;
- }
-
- protected Rectangle layout(int x, int y, int width, LayoutInfo info) {
- int viewWidth = Math.max(0, width - info.leftMargin - info.rightMargin);
- if (this.m_width > 0 && this.m_width < viewWidth) {
- viewWidth = this.m_width;
- }
-
- super.m_bounds = new Rectangle(x, y, viewWidth, this.m_size + 2 * this.m_borderSize + super.m_insets.top + super.m_insets.bottom);
- return super.m_bounds;
- }
-
- public void paint(Graphics g, Shape alloc) {
- Color oldColor = g.getColor();
- Color c = Color.lightGray;
- g.setColor(c);
- int x = super.m_bounds.x;
- int y = super.m_bounds.y + super.m_insets.top;
- int w = super.m_bounds.width - 2 * this.m_borderSize;
- int h = this.m_size + 1;
- if (this.m_pctWidth > 0.0F && this.m_pctWidth <= 1.0F) {
- w = (int)(this.m_pctWidth * (float)w);
- } else if (this.m_width > 0) {
- w = this.m_width;
- }
-
- if (w > super.m_bounds.width) {
- w = super.m_bounds.width;
- }
-
- if (super.m_alignment == 1) {
- x += (super.m_bounds.width - 2 * this.m_borderSize - w) / 2;
- } else if (super.m_alignment == 2) {
- x += super.m_bounds.width - 2 * this.m_borderSize - w;
- }
-
- if (this.m_bNoShade) {
- g.setColor(c.darker());
- g.fillRect(x, y, w, this.m_size);
- } else {
- Utilities.drawBorder(g, new Rectangle(x, y, w + 1, h + 1));
- }
-
- g.setColor(oldColor);
- }
- }
-